package meicai.appium.tests;

import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import meicai.appium.pages.control.OrderControl;
import meicai.appium.utils.Log;

public class OrderBuyOnlineWithCoupon extends BaseTest{
	public Log logger = Log.getLogger(OrderBuyOnlineWithCoupon.class);
	public OrderControl orderC;
	
	@BeforeClass
	public void initClass() {
		orderC = new OrderControl();
	}
	
	@BeforeMethod
	public void initMethod() {
		orderC.startApp();
	}
	
	private void init() {
		orderC.closeAdvertDialog();
	}
	
	private void done(String firstClass, String goodsName) {
		done(firstClass, null, goodsName);
	}
	
	private void done(String firstClass,String secondClass, String goodsName) {
		init();
		
		orderC.selectFirstClass(firstClass);
		
		if(secondClass != null) {
			orderC.selectSecondClass(secondClass);
		}
		
		orderC.goToGoodsInfo(goodsName);
		
		orderC.addGoodsToShop();
		
		orderC.payOnLineWithCoupon();
	}
	
	@Test(description = "在线支付，使用优惠券")
	public void buyOnLineUseCoupon() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("时令水果","精品类","泰国椰青");
		
	}
	
	@Test(description = "促销商品-在线支付，使用优惠券")
	public void buyOnLineUseCouponSalesPromotion() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("休闲酒饮","啤酒","青岛啤酒");
	}
	
	@Test(description = "秒杀商品-在线支付，使用优惠券")
	public void buyOnLineUseCouponSenconds() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("餐厨用品", "纸品湿巾","抽取式餐巾纸");
	}
	
	@Test(description = "满赠商品-在线支付，使用优惠券")
	public void buyOnLineUseCouponFullGifts() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("水产冻货","鱼丸火锅类","鱼豆腐");
	}
	
	@Test(description = "买赠商品-在线支付，使用优惠券")
	public void buyOnLineUseCouponBuyGifts() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("米面粮油","大米","东北大米");
	}
	
	@Test(description = "满返商品-在线支付，使用优惠券")
	public void buyOnLineUseCouponBuyBack() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("蛋类","鸡蛋");
	}
	
	@Test(description = "套餐商品-在线支付，使用优惠券")
	public void buyOnLineUseCouponPackageGoods() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("新鲜蔬菜","叶菜类","圆生菜");
	}
	
	@Test(description = "多货主商品-在线支付，使用优惠券")
	public void buyOnLineUseCouponMoreSeller() {
		logger.debug("OrderBuyOnlineWithCoupon");
		done("半成品","油菜");
	}
	
	@AfterMethod
	public void afterMethod() {
		orderC.quitApp();
	}

	@AfterClass
	public void afterClass() {
		
	}
}
